﻿#include "DrawForm.h"
#include "ui_DrawForm.h"

#include <QDebug>
#include <QMouseEvent>
#include <QPainter>
#include <QTimer>

const int MOUSE2PT = 36;

DrawForm::DrawForm(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::DrawForm)
    , m_drawMode(DRAW_NULL)
    , m_selectedLineId(-1)
    , m_selectedPtId(-1)
    , m_selectedPolygonId(-1)
    , m_selectedRectId(-1)
    , m_image()
    , image(QImage())
{
    ui->setupUi(this);


    m_ptColor = QColor(255, 0, 0, 255);

    m_alarmColor = QColor(255, 0, 0, 255); //红色

    m_detectColor = QColor(255, 255, 0, 255); //黄色

    m_ptRadius = 4;

    m_lineColor = QColor(255, 0, 0, 255);
    m_lineWidth = 2;

    m_rect.rect.setBottomLeft(QPoint(0, 0));
    m_rect.rect.setBottomRight(QPoint(0, 0));
}

DrawForm::~DrawForm()
{
    delete ui;
}

void DrawForm::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    //背景
    QPainter painter(this);
    painter.setRenderHints(QPainter::Antialiasing);
    painter.setPen(Qt::NoPen);
    painter.setBrush(QColor(0, 6, 37));
    painter.save();
    painter.drawRect(0, 0, this->width(), this->height());
    painter.restore();
    // 画图片
    if(!m_image.empty())
    {
        QImage image = QImage::fromData((uchar *)m_image.data(), m_image.size());
        QPainter painter(this);
        painter.setRenderHints(QPainter::Antialiasing);
        painter.drawImage(0, 0, image.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
    }
    else
    {
        painter.save();
        painter.setFont(QFont("Times", 25, QFont::Bold));
        painter.setPen(Qt::red);
        painter.drawText(rect(), Qt::AlignCenter, "实时预览");
        painter.restore();
    }
    // 画线
    for(auto line : m_lines)
    {
        paintAlarmLine(line);
    }
    for(auto line : m_detect_lines)
    {
        paintLine(line);
    }
    if(!m_line.line.isNull())
    {
        paintLine(m_line);
    }

    // 画多边形
    for(auto polygon : m_polygons)
    {
        paintAlarmPolygon(polygon);
    }
    for(auto polygon : m_detect_polygons)
    {
        paintPolygon(polygon);
    }
    if(!m_polygon.polygon.isEmpty())
    {
        paintPolygon(m_polygon);
    }

    // 画矩形
    for(auto rect : m_rects)
    {
        paintAlarmRect(rect);
    }
    for(auto rect : m_detect_rects)
    {
        paintRect(rect);
    }
    if(!m_rect.rect.isEmpty() && (m_rect.rect.topLeft() != m_rect.rect.bottomRight()))
    {
        paintRect(m_rect);
    }
    if(compare_rect.rect.topLeft() != compare_rect.rect.bottomRight())
        paintRect(compare_rect, QColor(255, 2, 126, 255));

}

void DrawForm::mousePressEvent(QMouseEvent *event)
{

    if(event->button() == Qt::LeftButton)
    {
        QPoint pressPt = event->pos();
        m_lastPressPt = pressPt;
        if(m_drawMode == DRAW_LINE)
        {
            for(int i = 0; i < m_detect_lines.count(); ++i)
            {
                m_detect_lines[i].selected = isInLine(pressPt, m_detect_lines.at(i).line);

                // 防止重复选中
                if(m_detect_lines.at(i).selected)
                {
                    m_selectedLineId = i;
                    m_selectedLine = m_detect_lines.at(i).line;

                    // 被选中线段的端点
                    QList<QPoint> selectedPts;
                    selectedPts.push_back(m_selectedLine.p1());
                    selectedPts.push_back(m_selectedLine.p2());

                    for(int i = 0; i < selectedPts.count(); ++i)
                    {
                        if(p2pLen(pressPt, selectedPts.at(i)) < MOUSE2PT)
                        {
                            m_selectedPtId = i;
                            break;
                        }
                    }

                    // 被选中线段序号后的所有线段清除选中效果
                    for(int j = i + 1; j < m_detect_lines.count(); ++j)
                    {
                        m_detect_lines[j].selected = false;
                    }
                    break;
                }

                // 遍历后没有选中线段
                if(i == m_detect_lines.count() - 1)
                {
                    m_selectedLineId = -1;
                }
            }

            if(m_selectedLineId != -1)
            {
                return;
            }

            m_line.line.setP1(pressPt);
            m_line.selected = true;
        }

        if(m_drawMode == DRAW_POLYGON)
        {
            for(int i = 0; i < m_detect_polygons.count(); ++i)
            {
                m_detect_polygons[i].selected = isInPolygon(pressPt, m_detect_polygons.at(i).polygon);
                // 防止重复选中
                if(m_detect_polygons.at(i).selected)
                {
                    m_selectedPolygonId = i;
                    m_selectedPolygon = m_detect_polygons.at(i).polygon;

                    for(int i = 0; i < m_selectedPolygon.count(); ++i)
                    {
                        if(p2pLen(pressPt, m_selectedPolygon.at(i)) < MOUSE2PT)
                        {
                            m_selectedPtId = i;
                            break;
                        }
                    }

                    // 被选中多边形序号后的所有多边形清除选中效果
                    for(int j = i + 1; j < m_detect_polygons.count(); ++j)
                    {
                        m_detect_polygons[j].selected = false;
                    }

                    break;
                }

                // 遍历后没有选中多边形
                if(i == m_detect_polygons.count() - 1)
                {
                    m_selectedPolygonId = -1;
                }
            }

            if(m_selectedPolygonId != -1)
            {
                return;
            }

            m_polygon.polygon.push_back(pressPt);
            m_polygon.selected = true;
        }

        if(m_drawMode == DRAW_RECT)
        {
            for(int i = 0; i < m_detect_rects.count(); ++i)
            {
                if(m_detect_rects[i].right)continue;
                m_detect_rects[i].selected = m_detect_rects.at(i).rect.contains(pressPt);
                if(m_detect_rects.at(i).selected)
                {
                    m_selectedRectId = i;
                    m_selectedRect = m_detect_rects.at(i).rect;

                    QList<QPoint> selectedPts;
                    selectedPts.push_back(m_selectedRect.topLeft());
                    selectedPts.push_back(m_selectedRect.topRight());
                    selectedPts.push_back(m_selectedRect.bottomLeft());
                    selectedPts.push_back(m_selectedRect.bottomRight());

                    for(int i = 0; i < selectedPts.count(); ++i)
                    {
                        if(p2pLen(pressPt, selectedPts.at(i)) < MOUSE2PT)
                        {
                            m_selectedPtId = i;
                            break;
                        }
                    }


                    // 被选中矩形序号后的所有多边形清除选中效果
                    for(int j = i + 1; j < m_detect_rects.count(); ++j)
                    {
                        m_detect_rects[j].selected = false;
                    }

                    break;
                }

                // 遍历后没有选中矩形
                if(i == m_detect_rects.count() - 1)
                {
                    m_selectedRectId = -1;
                }
            }

            if(m_selectedRectId != -1)
            {
                return;
            }

            m_rect.rect.setTopLeft(pressPt);
            m_rect.selected = true;
            m_rect.right = false;
        }
    }

    if(event->button() == Qt::RightButton)
    {
        QPoint pressPt = event->pos();
        m_lastPressPt = pressPt;
        if(m_drawMode == DRAW_POLYGON)
        {
            if(m_polygon.polygon.count() >= 3)
            {
                m_polygon.selected = false;
                m_detect_polygons.push_back(m_polygon);
            }

            m_polygon.polygon.clear();
        }

        if(m_drawMode == DRAW_RECT)
        {
            for(int i = 0; i < m_detect_rects.count(); ++i)
            {
                if(!m_detect_rects[i].right)continue;
                m_detect_rects[i].selected = m_detect_rects.at(i).rect.contains(pressPt);
                if(m_detect_rects.at(i).selected)
                {
                    m_selectedRectId = i;
                    m_selectedRect = m_detect_rects.at(i).rect;

                    QList<QPoint> selectedPts;
                    selectedPts.push_back(m_selectedRect.topLeft());
                    selectedPts.push_back(m_selectedRect.topRight());
                    selectedPts.push_back(m_selectedRect.bottomLeft());
                    selectedPts.push_back(m_selectedRect.bottomRight());

                    for(int i = 0; i < selectedPts.count(); ++i)
                    {
                        if(p2pLen(pressPt, selectedPts.at(i)) < MOUSE2PT)
                        {
                            m_selectedPtId = i;
                            break;
                        }
                    }


                    // 被选中矩形序号后的所有多边形清除选中效果
                    for(int j = i + 1; j < m_detect_rects.count(); ++j)
                    {
                        m_detect_rects[j].selected = false;
                    }

                    break;
                }

                // 遍历后没有选中矩形
                if(i == m_detect_rects.count() - 1)
                {
                    m_selectedRectId = -1;
                }
            }

            if(m_selectedRectId != -1)
            {
                return;
            }

            m_rect.rect.setTopLeft(pressPt);
            m_rect.selected = true;
            m_rect.right = false;
            m_rect.rect.setTopLeft(pressPt);
            m_rect.selected = true;
            m_rect.right = true;
        }
    }
}



void DrawForm::mouseMoveEvent(QMouseEvent *event)
{
    QPoint pt = event->pos();

    if(pt.x() <= 0 || pt.x() >= this->width() || pt.y() <= 0 || pt.y() >= this->height())
    {
        return;
    }

    // 鼠标移动的相对距离
    QPoint moveLen = this->mapToGlobal(pt) - this->mapToGlobal(m_lastPressPt);

    if(m_drawMode == DRAW_LINE)
    {
        if(m_selectedLineId == -1)
        {
            m_line.line.setP2(pt);
        }
        else
        {
            if(m_selectedPtId == -1)
            {
                QPoint p1 = m_selectedLine.p1() + moveLen;
                QPoint p2 = m_selectedLine.p2() + moveLen;

                m_detect_lines[m_selectedLineId].line = QLine(p1, p2);
            }
            else
            {
                if(m_selectedPtId == 0)
                {
                    m_detect_lines[m_selectedLineId].line.setP1(pt);
                }
                else if(m_selectedPtId == 1)
                {
                    m_detect_lines[m_selectedLineId].line.setP2(pt);
                }
            }
        }
    }

    if(m_drawMode == DRAW_POLYGON)
    {
        if(m_selectedPolygonId != -1)
        {
            if(m_selectedPtId == -1)
            {
                QPolygon polygon;

                for(int i = 0; i < m_selectedPolygon.count(); ++i)
                {
                    polygon.push_back(m_selectedPolygon.at(i) + moveLen);
                }

                m_detect_polygons[m_selectedPolygonId].polygon = polygon;
            }
            else
            {
                m_detect_polygons[m_selectedPolygonId].polygon[m_selectedPtId].setX(pt.x());
                m_detect_polygons[m_selectedPolygonId].polygon[m_selectedPtId].setY(pt.y());
            }
        }
    }

    if(m_drawMode == DRAW_RECT)
    {
        if(m_selectedRectId == -1)
        {
            m_rect.rect.setBottomRight(pt);
        }
        else
        {
            if(m_selectedPtId == -1)
            {
                QPoint topLeft = m_selectedRect.topLeft() + moveLen;
                QPoint bottomRight = m_selectedRect.bottomRight() + moveLen;

                m_detect_rects[m_selectedRectId].rect.setTopLeft(topLeft);
                m_detect_rects[m_selectedRectId].rect.setBottomRight(bottomRight);
            }
            else
            {
                if(m_selectedPtId == 0)
                {
                    QPoint topLeft = m_selectedRect.topLeft() + moveLen;
                    m_detect_rects[m_selectedRectId].rect.setTopLeft(topLeft);
                }
                else if(m_selectedPtId == 1)
                {
                    QPoint topRight = m_selectedRect.topRight() + moveLen;
                    m_detect_rects[m_selectedRectId].rect.setTopRight(topRight);
                }
                else if(m_selectedPtId == 2)
                {
                    QPoint bottomLeft = m_selectedRect.bottomLeft() + moveLen;
                    m_detect_rects[m_selectedRectId].rect.setBottomLeft(bottomLeft);
                }
                else if(m_selectedPtId == 3)
                {
                    QPoint bottomRight = m_selectedRect.bottomRight() + moveLen;
                    m_detect_rects[m_selectedRectId].rect.setBottomRight(bottomRight);
                }
            }
        }
    }

    this->update();
}

void DrawForm::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        if(m_drawMode == DRAW_LINE)
        {
            if(m_selectedLineId == -1)
            {
                m_line.selected = false;

                if(p2pLen(m_line.line.p1(), m_line.line.p2()) > 10)
                {
                    m_detect_lines.push_back(m_line);
                }

                m_line.line.setLine(0, 0, 0, 0);
            }
            else
            {
                m_selectedPtId = -1;
                m_detect_lines[m_selectedLineId].selected = false;
                m_selectedLine.setLine(0, 0, 0, 0);
            }
        }

        if(m_drawMode == DRAW_POLYGON)
        {
            m_selectedPolygon.clear();
            if(m_selectedPolygonId != -1)
                m_detect_polygons[m_selectedPolygonId].selected = false;
            m_selectedPtId = -1;
        }

        if(m_drawMode == DRAW_RECT)
        {
            if(m_selectedRectId == -1)
            {
                m_rect.selected = false;

                if(!m_rect.rect.topLeft().isNull() && !m_rect.rect.bottomRight().isNull())
                {
                    if(p2pLen(m_rect.rect.topLeft(), m_rect.rect.bottomRight()) > 10)
                    {
                        m_detect_rects.push_back(m_rect);
                    }
                }

                m_rect.rect.setBottomLeft(QPoint(0, 0));
                m_rect.rect.setBottomRight(QPoint(0, 0));
            }
            else
            {
                //m_detect_rects[m_selectedRectId].selected = false;
                if(m_selectedPtId == -1)
                {
                    m_selectedRect.setTopLeft(QPoint(0, 0));
                    m_selectedRect.setBottomRight(QPoint(0, 0));
                    m_selectedRectId = -1;
                }
                else
                {
                    m_selectedPtId = -1;
                    m_selectedRect.setTopLeft(QPoint(0, 0));
                    m_selectedRect.setTopRight(QPoint(0, 0));
                    m_selectedRect.setBottomLeft(QPoint(0, 0));
                    m_selectedRect.setBottomRight(QPoint(0, 0));
                }
            }
        }
    }
    if(event->button() == Qt::RightButton)
    {
        if(m_drawMode == DRAW_RECT)
        {
            if(m_selectedRectId == -1)
            {
                m_rect.selected = false;

                if(!m_rect.rect.topLeft().isNull() && !m_rect.rect.bottomRight().isNull())
                {
                    if(p2pLen(m_rect.rect.topLeft(), m_rect.rect.bottomRight()) > 10)
                    {
                        m_detect_rects.push_back(m_rect);
                    }
                }

                m_rect.rect.setBottomLeft(QPoint(0, 0));
                m_rect.rect.setBottomRight(QPoint(0, 0));
            }
            else
            {
                if(m_selectedPtId == -1)
                {

                    m_selectedRect.setTopLeft(QPoint(0, 0));
                    m_selectedRect.setBottomRight(QPoint(0, 0));
                    m_selectedRectId = -1;
                }
                else
                {
                    m_selectedPtId = -1;
                    m_selectedRect.setTopLeft(QPoint(0, 0));
                    m_selectedRect.setTopRight(QPoint(0, 0));
                    m_selectedRect.setBottomLeft(QPoint(0, 0));
                    m_selectedRect.setBottomRight(QPoint(0, 0));
                }
            }
        }
    }

    this->update();
}



void DrawForm::paintLine(const DrawLine &line)
{
    QPainter painter(this);
    painter.setRenderHints(QPainter::Antialiasing);

    if(line.selected)
    {
        // 画刷用于填充
        painter.setPen(Qt::NoPen);
        painter.setBrush(m_detectColor);
        painter.save();
        painter.drawEllipse(line.line.p1(), m_ptRadius, m_ptRadius);
        painter.drawEllipse(line.line.p2(), m_ptRadius, m_ptRadius);
        painter.restore();
    }

    // 画笔用于划线
    painter.setPen(QPen(m_detectColor, m_lineWidth));
    painter.setBrush(Qt::NoBrush);
    painter.save();
    painter.drawLine(line.line);
    painter.restore();
}

void DrawForm::paintAlarmLine(const DrawForm::DrawLine &line)
{
    QPainter painter(this);
    painter.setRenderHints(QPainter::Antialiasing);
    // 画笔用于划线
    painter.setPen(QPen(m_alarmColor, m_lineWidth));
    painter.setBrush(Qt::NoBrush);
    painter.save();
    painter.drawLine(line.line);
    painter.restore();
}

void DrawForm::paintPolygon(const DrawPolygon &polygon)
{
    QPainter painter(this);
    // 抗锯齿
    painter.setRenderHints(QPainter::Antialiasing);

    if(polygon.selected)
    {
        painter.setPen(Qt::NoPen);
        painter.setBrush(m_detectColor);
        painter.save();

        for(auto pt : polygon.polygon)
        {
            painter.drawEllipse(pt, m_ptRadius, m_ptRadius);
        }

        painter.restore();
    }

    painter.setPen(QPen(m_detectColor, m_lineWidth));
    painter.setBrush(Qt::NoBrush);
    painter.save();
    painter.drawPolygon(polygon.polygon);
    painter.restore();
}

void DrawForm::paintAlarmPolygon(const DrawForm::DrawPolygon &polygon)
{
    QPainter painter(this);
    // 抗锯齿
    painter.setRenderHints(QPainter::Antialiasing);
    painter.setPen(QPen(m_alarmColor, m_lineWidth));
    painter.setBrush(Qt::NoBrush);
    painter.save();
    painter.drawPolygon(polygon.polygon);
    painter.restore();

}

void DrawForm::paintRect(const DrawRect &rect, QColor color)
{
    QPainter painter(this);
    // 抗锯齿
    painter.setRenderHints(QPainter::Antialiasing);

    if(rect.selected)
    {
        painter.save();
        painter.setPen(Qt::NoPen);
        painter.setBrush(color);

        painter.drawEllipse(rect.rect.topLeft(), m_ptRadius, m_ptRadius);
        painter.drawEllipse(rect.rect.bottomLeft(), m_ptRadius, m_ptRadius);
        painter.drawEllipse(rect.rect.topRight(), m_ptRadius, m_ptRadius);
        painter.drawEllipse(rect.rect.bottomRight(), m_ptRadius, m_ptRadius);

        painter.restore();
    }

    painter.setPen(QPen(color, m_lineWidth));
    painter.setBrush(Qt::NoBrush);
    painter.save();
    painter.drawRect(rect.rect);
    painter.drawText(rect.rect.topLeft() - QPoint(0, 5), QString("%1").arg(rect.desc));
    painter.restore();
}



void DrawForm::paintAlarmRect(const DrawRect &rect)
{
    QPainter painter(this);
    painter.save();
    // 抗锯齿
    painter.setRenderHints(QPainter::Antialiasing);

    painter.setPen(QPen(m_alarmColor, m_lineWidth));
    painter.setBrush(Qt::NoBrush);

    painter.drawRect(rect.rect);
    painter.drawText(rect.rect.topLeft() - QPoint(0, 5), QString("%1").arg(rect.desc));
    painter.restore();
}

bool DrawForm::isInLine(const QPoint &p, const QLine &line)
{
    // 线段上的点到两个端点的距离等于线段的长度
    double lineLen = p2pLen(line.p1(), line.p2());
    double p2p1Len = p2pLen(p, line.p1());
    double p2p2Len = p2pLen(p, line.p2());

    if(fabs(lineLen - (p2p1Len + p2p2Len)) < 10)
    {
        return true;
    }
    else
    {
        return false;
    }
}

double DrawForm::p2pLen(const QPoint &p1, const QPoint &p2)
{
    return sqrt(pow((p1.x() - p2.x()), 2) + pow((p1.y() - p2.y()), 2));
}

bool DrawForm::isInPolygon(const QPoint &p, const QPolygon &polygon)
{
    const int cnt = polygon.count();

    if(cnt < 3)
    {
        return false;
    }

    QList<int> xVec, yVec;
    for(auto pt : polygon)
    {
        xVec.push_back(pt.x());
        yVec.push_back(pt.y());
    }

    // 计算鼠标点击是否在多边形内部
    int x = p.x();
    int y = p.y();

    bool c = false;
    for(int i = 0, j = cnt - 1; i < cnt; j = i++)
    {
        bool b1 = (yVec.at(i) > y) != (yVec.at(j) > y);
        int diff = 1;
        if((yVec.at(j) - yVec.at(i)) != 0)
        {
            diff = (yVec.at(j) - yVec.at(i));
        }

        bool b2 = (x < (xVec.at(j) - xVec.at(i)) * (y - yVec.at(i)) / diff + xVec.at(i));

        if(b1 && b2)
        {
            c = !c;
        }
    }

    return c;
}

QList<DrawForm::DrawLine> DrawForm::lines() const
{
    return m_detect_lines;
}

void DrawForm::setLines(const QList<DrawLine> &lines)
{
    m_lines = lines;
}

QList<DrawForm::DrawPolygon> DrawForm::polygons() const
{
    return m_detect_polygons;
}

void DrawForm::setPolygons(const QList<DrawPolygon> &polygons)
{
    m_polygons = polygons;
}

QList<DrawForm::DrawRect> DrawForm::rects() const
{
    return m_detect_rects;
}

void DrawForm::setRects(const QList<DrawRect> &rects)
{
    m_rects = rects;
}

void DrawForm::set_detect_Rects(const QList<DrawRect> &rects)
{
    m_detect_rects = rects;
}

void DrawForm::set_detect_Lines(const QList<DrawLine> &lines)
{
    m_detect_lines = lines;
}

void DrawForm::set_detect_Polygons(const QList<DrawPolygon> &polygons)
{
    m_detect_polygons = polygons;
}

void DrawForm::set_compare_rect(const DrawForm::DrawRect &rect)
{
    compare_rect = rect;
}

void DrawForm::setDrawMode(int drawMode)
{
    m_drawMode = drawMode;
}

void DrawForm::clearLines()
{
    m_lines.clear();
    m_detect_lines.clear();
    m_selectedLineId = -1;

    this->update();
}

void DrawForm::clearPolygons()
{
    m_polygons.clear();
    m_detect_polygons.clear();
    m_selectedPolygonId = -1;

    this->update();
}

void DrawForm::clearRects()
{
    m_rects.clear();
    m_detect_rects.clear();
    m_selectedRectId = -1;

    this->update();
}

void DrawForm::clearImage()
{
    m_image.clear();
    this->update();
}

void DrawForm::clear()
{
    QTimer::singleShot(1000, this, [ = ]
    {
        qDebug() << "clear";
        this->clearLines();
        this->clearRects();
        this->clearPolygons();
        this->clearImage();
    });
}


void DrawForm::setImage(QByteArray imageArr)
{
    m_image = imageArr.toStdString();
    this->update();
}

QPoint DrawForm::pointF2Point(QPointF pointF)
{
    QPoint point;
    point.setX(static_cast<int>(static_cast<float>(this->width()) * pointF.x()));
    point.setY(static_cast<int>(static_cast<float>(this->height()) * pointF.y()));

    return point;
}

QPointF DrawForm::point2PointF(QPoint point)
{
    QPointF pointF;
    pointF.setX(static_cast<float>(point.x()) / static_cast<float>(this->width()));
    pointF.setY(static_cast<float>(point.y()) / static_cast<float>(this->height()));

    return pointF;
}

QRect DrawForm::rectF2Rect(QRectF rectF)
{
    QRect rect;
    rect.setX(static_cast<int>(static_cast<float>(this->width()) * rectF.x()));
    rect.setY(static_cast<int>(static_cast<float>(this->height()) * rectF.y()));
    rect.setWidth(static_cast<int>(static_cast<float>(this->width()) * rectF.width()));
    rect.setHeight(static_cast<int>(static_cast<float>(this->height()) * rectF.height()));

    return rect;
}

QRectF DrawForm::rect2RectF(QRect rect)
{
    QRectF rectF;
    rectF.setX(static_cast<float>(rect.x()) / static_cast<float>(this->width()));
    rectF.setY(static_cast<float>(rect.y()) / static_cast<float>(this->height()));
    rectF.setWidth(static_cast<float>(rect.width()) / static_cast<float>(this->width()));
    rectF.setHeight(static_cast<float>(rect.height()) / static_cast<float>(this->height()));

    return rectF;
}
